home
***
CD-ROM
|
disk
|
other
***
search
/
SGI Hot Mix 8
/
Hot Mix 8.iso
/
.all
/
demos
/
Imagicians
/
InstallIt2
(
.txt
)
< prev
next >
Wrap
Text File
|
1994-06-22
|
11KB
|
363 lines
#!/bin/csh -f
#
# MYAPP = name of the application executable
# INST_DIR = name of the installation directory that will be created
# (this is the directory name, not the full path name)
# CD_PATH = directory path of the location of the software
# on the HotMix CD-ROM (it must begin with "$HOTMIXDIR",
# which is the mount point for the CD-ROM drive).
# KBYTES_REQ = required size of the full installation (in Kbytes).
#
# You will also need to change the MYAPP, INST_DIR, and CD_PATH
# parameters in the InstallIt, RemoveIt, and RemoveIt2 scripts.
#
# In this simple example, the installation just involves copying
# the software to the hard disk, and then launching the application.
#
# For the given parameters in this example, if there is enough space
# in /usr, the entire $HOTMIXDIR/demos/Digital_Media/SGI directory
# will be copied into a directory named /usr/tmp/SGI. If the user
# specifies a different installation directory, the full pathname
# of the base directory is read. So, if the user enters /disk2/tmp,
# the entire $HOTMIXDIR/demos/Digital_Media/SGI will be copied
# into a directory named /disk2/tmp/SGI. In this case, the application
# is then launched by executing /disk2/tmp/SGI/showcase.
#
# In your situation, the installation will probably be more complicated,
# so you'll need to change the code at the end of the script, as well
# (ie., change the code following the "---------").
#
# The rest of the script should not require modification.
#
# All of the InstallIt and RemoveIt scripts should reside in the
# $CD_PATH directory.
#
# Marvin Kong
# Silicon Graphics, Inc.
# 4/9/93
set MYAPP=Chances_Art.csh
set INST_DIR=Imagicians
set CD_PATH=$HOTMIXDIR/demos/Imagicians
set KBYTES_REQ=20050
#
# Test to see if on the new Indy filesystem or old one.
#
set TEST_NEW=`df -k /usr | /usr/bin/awk '{print $7}'`
if ( "$TEST_NEW" == "Mounted /" ) then
set FILE_STRUCTURE=new
else
set FILE_STRUCTURE=old
endif
#
# Determine the INST_PATH name.
#
# First try /usr/tmp; then if necessary, ask for another directory.
#
if ( $KBYTES_REQ < 1000 ) then
set MBYTES_REQ=1
else
@ MBYTES_REQ = ($KBYTES_REQ) / 1000
endif
if ( $FILE_STRUCTURE == "new" ) then
set KBYTES_AVAIL=`df -k / | /bin/grep / | /usr/bin/awk '{print $5}'`
else
set KBYTES_AVAIL=`df -k /usr | /bin/grep /usr | /usr/bin/awk '{print $5}'`
endif
if ( -w /usr/tmp ) then
if ( $KBYTES_AVAIL > $KBYTES_REQ ) then
set INST_PATH=/usr/tmp/$INST_DIR
echo " "
echo "This demo requires $MBYTES_REQ Mbytes of disk space."
echo " "
echo "It will be installed in a directory named $INST_PATH"
echo "Is this OK (y/n)? \c"
set ans=($<)
if ( $ans != 'y' ) then
echo " "
echo "Do you want to install in another directory (y/n)? \c"
set ans2=($<)
if ( $ans2 != 'y' ) then
echo " "
echo "... Bye."
sleep 3
exit
else
set INST_PATH=none
endif
else
if ( -d $INST_PATH ) then
echo " "
echo "It seems the demo is already installed. Continue anyway (y/n)? \c"
set ans3=($<)
if ( $ans3 != 'y' ) then
echo " "
echo "... Bye."
sleep 3
exit
endif
rm -rf $INST_PATH
endif
endif
else
set INST_PATH=none
endif
else
set INST_PATH=none
endif
if ( $INST_PATH == "none" ) then
# Read name of installation directory.
echo " "
echo "This demo requires $MBYTES_REQ Mbytes of disk space."
LOOP1:
unset INSTDIR_FILESYS
echo " "
echo "Enter the full path name of an existing directory"
echo "in which to copy the software (or enter 'q' to quit): \c"
set ans=($<)
# Check validity of the path name. If it contains only a "/",
# this will cause a divide by zero, and fail.
set TEST1=`echo $ans | cut -f2 -d"/"`
if ( ! $#TEST1 ) then
echo " "
echo "You cannot use directory /. Please try again."
goto LOOP1
endif
if ( $ans == 'q' ) then
echo " "
echo "... Bye."
sleep 3
exit
else if ( $#ans == 0 ) then
echo " "
echo "Input error. Please try again."
goto LOOP1
else
# Check validity of the path name again. It must begin with "/".
set TEST2=`echo $ans | cut -f1 -d"/" -s`
set TEST3=`echo $ans | cut -f2 -d"/" -s`
if ( ( $#TEST2 ) || ( ! $#TEST3 ) ) then
echo " "
echo "The pathname must begin with /. Please try again."
goto LOOP1
endif
if ( -d $ans ) then
echo " "
echo "A $INST_DIR directory will be created in $ans."
echo "Is this OK (y/n)?: \c"
set ans2=($<)
if ( $ans2 != 'y' ) goto LOOP1
# Determine the space available for the filesystem
# containing the requested directory.
#
# Check to see if the directory is actually a link or an
# nfs mount and do appropriate checks.
if ( -l $ans ) then
cd $ans
set CDIR=`pwd`
set KBYTES_AVAIL=`df -k $CDIR | /usr/bin/awk '{print $5}'`
endif
touch $ans/hmtest
if ( ! -r $ans/hmtest ) then
echo "Can not write to $ans, please choose another directory."
goto LOOP1
endif
/bin/rm -f $ans/hmtest
# First, find all the mounted filesystems.
set FILESYSTEMS=`df -k | awk '{print $7}' | grep /`
# Now, beginning with the full path name of the
# requested directory, start stripping off the trailing
# subdirectory names, and compare this to the existing
# file system names. If these match exactly, then we've
# found the right file system.
set TEST4=`echo $ans | cut -f3 -d"/"`
if ( ! $#TEST4 ) then
set PATH=$ans
else
set PATH=`dirname $ans`
endif
LOOP2:
foreach FILESYSTEM ($FILESYSTEMS)
# Don't do the test if $FILESYSTEM == "/"
set TEST5=`echo $FILESYSTEM | cut -f2 -d"/"`
if ( $#TEST5 != 0 ) then
if ( $PATH == $FILESYSTEM ) then
set INSTDIR_FILESYS=$PATH
endif
endif
end
set PATH=`dirname $PATH`
# Continue looping until we've stripped the pathname
# down to only "/", or until we find the file system.
set LOOPTEST=`echo $PATH | cut -f2 -d"/"`
if (( $#LOOPTEST != 0 ) && ( ! $?INSTDIR_FILESYS )) goto LOOP2
if ( $?INSTDIR_FILESYS ) then
# Determine the available space
set KBYTES_AVAIL=`df -k $INSTDIR_FILESYS | /bin/grep $INSTDIR_FILESYS | /usr/bin/awk '{print $5}'`
else
if ( $FILE_STRUCTURE == "new" ) then
set KBYTES_AVAIL=`df -k / | /bin/grep / | /usr/bin/awk '{print $5}'`
else
echo " "
echo " ERROR: Can't determine the amount of available disk"
echo " space for the directory you requested."
echo " "
echo " Continue anyway (y/n)? \c"
set ans3=($<)
if ( $ans3 == 'y' ) then
@ KBYTES_AVAIL = ($KBYTES_REQ) + 1
else
echo " "
echo "... Bye."
sleep 3
exit
endif
endif
endif
if ( $KBYTES_AVAIL > $KBYTES_REQ ) then
if ( -w $ans ) then
# Success!!!
set INST_PATH=$ans/$INST_DIR
echo " "
else
echo " "
echo "Can't write to directory $ans."
echo "Please try again."
goto LOOP1
endif
else
echo " "
echo "Not enough disk space available."
echo " "
echo " Required space = $KBYTES_REQ Kbytes"
echo " Available space = $KBYTES_AVAIL Kbytes"
echo " "
echo "Please try again."
goto LOOP1
endif
else
echo " "
echo "Can't find directory $ans."
goto LOOP1
endif
endif
# Check installation directory.
if ( -d $INST_PATH ) then
echo " "
echo "It seems the demo is already installed. Continue anyway (y/n)? \c"
set ans3=($<)
if ( $ans3 != 'y' ) then
echo " "
echo "... Bye."
sleep 3
exit
endif
rm -rf $INST_PATH
endif
endif
# Store INST_PATH in a file so it can be communicated to the RemoveIt script.
#
# First, try to put it in /usr/tmp. If we can't, then put it in /tmp
# and in the user's home directory. If put in /tmp, the file will
# disappear if the machine is rebooted. If put in the user's home
# directory, we won't be able to find it if the user trying to remove
# the software is not the same as the user who installed it. Either
# case isn't very good, but it's the best we can do if we can't write
# to /usr/tmp.
/bin/rm -f /usr/tmp/HOTMIXPATH_$INST_DIR > /dev/null
/bin/rm -f /tmp/HOTMIXPATH_$INST_DIR > /dev/null
/bin/rm -f ~/HOTMIXPATH_$INST_DIR > /dev/null
if ( -w /usr/tmp ) then
echo "setenv INST_PATH $INST_PATH" > /usr/tmp/HOTMIXPATH_$INST_DIR
/bin/chmod 666 /usr/tmp/HOTMIXPATH_$INST_DIR
else
echo "setenv INST_PATH $INST_PATH" > /tmp/HOTMIXPATH_$INST_DIR
/bin/chmod 666 /tmp/HOTMIXPATH_$INST_DIR
echo "setenv INST_PATH $INST_PATH" > ~/HOTMIXPATH_$INST_DIR
/bin/chmod 666 ~/HOTMIXPATH_$INST_DIR
endif
#
#-----------------------------------------------------------------------
#
# Now that we've finally determined INST_PATH, do the installation.
# In this case, just copy the software and execute the application.
echo " "
echo "Installing Chances_Art. Please wait..."
/bin/cp -r $CD_PATH $INST_PATH
echo " "
echo "Done."
echo " "
echo "To run the demo, move to the $INST_PATH directory"
echo "and execute Chances_Art."
echo " "
echo " "
echo "Do you want to run the demo now (y/n)? \c"
set ans=($<)
if ( $ans == 'y' ) then
cd $INST_PATH
./$MYAPP
# If your application is compiled so as to run in the background,
# you must execute it via the "wait.csh" script, as shown below
# (see the wait.csh script for more info).
# ./wait.csh ./$MYAPP
else
echo "... Bye."
sleep 3
endif